<template>
  <div class="pro-box">
    <h3>项目列表</h3>
    <el-card v-for="item in dataList" :key="item.id">
      <template #header>
        <router-link :to="'/detail/' + item.id">{{ item.proName }}</router-link>
      </template>

      <div>
        <ul>
          <li>
            <span>项目难度：</span>
            <p>
              <el-rate v-model="item.proNandu"></el-rate>
            </p>
          </li>
          <li>
            <span>技术栈：</span>
            <p>
              <el-tag v-for="item in item.proJishu.split(',')" :key="item">{{
                item
              }}</el-tag>
            </p>
          </li>
          <li>
            <span>开发人数：</span>
            <p>{{ item.proTuanduiNum }} 人</p>
          </li>
          <li>
            <span>点赞：</span>
            <p>({{ item.zanNum }})</p>
            <span>浏览量</span>
            <p>({{ item.readNum }})</p>
            <span>评价：</span>
            <p>({{ item.pingjiaNum }})</p>
          </li>
        </ul>
        <!-- 项目描述 -->
        <div class="desc">
          <h4>项目描述：</h4>
          <p>
            {{ item.proZaiyao }}
          </p>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
import { getProList } from '@/api/project.js'
export default {
  data() {
    return {
      star: 3,
      currentPage: 1,
      pageSize: 5,
      total: 0,
      dataList: []
    }
  },
  created() {
    this.getDatas()
  },
  methods: {
    async getDatas() {
      const { content, totalElements } = await getProList({
        page: this.currentPage,
        rows: this.pageSize,
        proTypeId: this.$id
      })
      console.log(content)
      this.dataList = content
      this.total = totalElements
    }
  },
  computed: {
    $id() {
      return this.$route.params.id
    }
  }
}
</script>

<style lang="less" scoped>
a {
  text-decoration: none;
  color: #666;
  font-size: 18px;
}

h3 {
  position: relative;
  margin: 10px 0 20px;
  text-indent: 8px;
  &::before {
    content: '';
    position: absolute;
    left: 0;
    width: 3px;
    height: 18px;
    background-color: #03a9f4;
  }
}

.el-card {
  margin-bottom: 20px;
}

.pro-box {
  width: 930px;
  max-width: 1120px;
  margin: 0 auto;
}

ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;

  li {
    width: 60%;
    color: #333;
    display: flex;
    margin-bottom: 15px;
    align-items: center;

    span {
      font-size: 16px;
      color: cornflowerblue;
      margin-right: 6px;
    }

    &:nth-of-type(2n-1) {
      width: 30%;
    }
    p {
      margin-right: 15px;
      color: #666;
    }
  }
}

h4 {
  margin: 10px 0;
  font-size: 16px;
  color: cornflowerblue;
}

.desc {
  p {
    text-indent: 2em;
    line-height: 24px;
    color: #666;
    font-size: 14px;

    word-break: break-word; //换行模式
    overflow: hidden;
    text-overflow: ellipsis; //修剪文字
    display: -webkit-box;
    -webkit-line-clamp: 2; //此处为上限行数
    -webkit-box-orient: vertical;
  }
}
</style>
